package com.cw1.factory.jdk;

import java.util.Calendar;

/**
 * @Author qiuMi
 * @description JDK - 源码 - 工厂模式
 * @Date 2022-10-06 22:18
 **/
public class JdkFactory {
    public static void main(String[] args) {
        // 通过getInstance 方法实例化
        Calendar calendar = Calendar.getInstance();
        // 因为月份下标是从0月起,所以月份要取 +1
        System.out.println("年" + calendar.get(Calendar.YEAR));
        System.out.println("月" + (calendar.get(Calendar.MONTH) + 1));
        System.out.println("日" + calendar.get(Calendar.DAY_OF_MONTH));
        System.out.println("时" + calendar.get(Calendar.HOUR_OF_DAY));
        System.out.println("分" + calendar.get(Calendar.MINUTE));
        System.out.println("秒" + calendar.get(Calendar.SECOND));
    }
}
